# 导入模块
import requests
import json


api_secret = "M7WLF7GIZ2bqhviCNeItw_ZR4pDYg_gP"
# 输入API_Key
api_key = 'fMCHY1PqQTQLWMxM787KAdNjm3AibZeR'  


# 目标url
BASE_URL = 'https://api-cn.faceplusplus.com/facepp/v3/detect' 
img_url = 'http://newmedia.nfu.edu.cn/wcy/wp-content/uploads/2018/04/post_20180424__NFU_DoraHacks_imoji%E5%9B%A2%E9%98%9F.jpg'

headers = {
    'Content-Type': 'application/json',
}

payload = {
    "image_url":img_url,
    'api_key': api_key,
    'api_secret': api_secret,
    'return_attributes':'gender,age,smiling,emotion', 
}

r = requests.post(BASE_URL, params=payload, headers=headers)

r.status_code
print(r.content)

# json转义
results = r.json()
results

# pandas数据表格化
import pandas as pd
df_face = pd.json_normalize(results)
df_face